package Polyglot;

import java.math.BigInteger;

import net.sourceforge.juint.UInt16;
import net.sourceforge.juint.UInt32;
import util.UInt64;

public class PgEntry {
	UInt64 key;
	UInt16 move;
	UInt16 weight;
	UInt32 learn;
		
	
	public PgEntry(byte[] bytes){
		this.setEntryFromByteArray(bytes);
	}
	
	public PgEntry(){
		this.key = new UInt64("0");
		this.move = new UInt16(0);
		this.weight = new UInt16(0);
		this.learn = new UInt32(0);
	}
	
	public PgEntry(UInt64 key, UInt16 move, UInt16 weight, UInt32 learn) {	
		this.key = key;
		this.move = move;
		this.weight = weight;
		this.learn = learn;
	}
	
	public UInt64 getKey() {
		return key;
	}
	public void setKey(UInt64 key) {
		this.key = key;
	}
	public UInt16 getMove() {
		return move;
	}
	public void setMove(UInt16 move) {
		this.move = move;
	}
	public UInt16 getWeight() {
		return weight;
	}
	public void setWeight(UInt16 weight) {
		this.weight = weight;
	}
	public UInt32 getLearn() {
		return learn;
	}
	public void setLearn(UInt32 learn) {
		this.learn = learn;
	}
	
	public void setEntryFromByteArray(byte[] bytes){
		byte key[] = new byte[8];
		byte move[] = new byte[2];
		byte weight[] = new byte[2];
		byte learn[] = new byte[4];
		
		int i=0;
		for(i=0;i<8;i++){
			key[i]=bytes[i];
		}
		for(i=0;i<2;i++){
			move[i]=bytes[i+8];
		}
		for(i=0;i<2;i++){
			weight[i]=bytes[i+10];
		}
		for(i=0;i<4;i++){
			learn[i]=bytes[i+12];
		}		
		this.key = new UInt64(key);
		this.move= new UInt16(move);
		this.weight=new UInt16(weight);
		this.learn= new UInt32(learn);
	}
}
